
//
// 101031 - AH - Created.
// 101109 - AH - subcase, metacase properties and getFullName(). 
// 101205 - AH - Now extends abstract test base class SoekratTestCase, moved
//               all name and keywords stuff there.
//

package org.soekrat.engine.wheel.test.util;

import java.io.CharArrayWriter;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;

import org.soekrat.AttributeObject;
import org.soekrat.engine.mine.Mine;
import org.soekrat.test.SoekratTestCase;

/**
 * <p>
 *   {@link MineSpokeTestCase} test case.
 * </p>
 * @author Arne Halvorsen (AH)
 * @author Laetitia Le Chatton (LLC) 
 */
public final class MineSpokeTestCase extends SoekratTestCase
{
  private final Map<String, AttributeObject> m_oneOf=
    new HashMap<String, AttributeObject>();
  
  private final Map<String, AttributeObject> m_all=
    new HashMap<String, AttributeObject>();
  
  private boolean m_pass=false;
  
  private Mine m_mine=null;
  
  /**
   * <p>
   *   Constructor.
   * </p>
   * @param name Test case name.
   */
  MineSpokeTestCase(String name){ super(name); }
  
  /**
   * <p>
   *   Sets
   *   {@link Mine}.
   * </p>
   * @param mine {@code Mine}.
   */
  void setMine(Mine mine){ m_mine=mine; }
  
  /**
   * <p>
   *   Gets
   *   {@link Mine}.
   * </p>
   * @return {@code Mine} or {@code null} if not sat.
   */
  public Mine getMine(){ return m_mine; }
  
  /**
   * <p>
   *   Adds a resource there should been matched on of.
   * </p>
   * @param ao Resource.
   */
  void addOneOf(AttributeObject ao){ m_oneOf.put(ao.getName(), ao); }
  
  /**
   * <p>
   *   Adds a resource that all should be matched.
   * </p>
   * @param ao Resources.
   */
  void addAll(AttributeObject ao){ m_all.put(ao.getName(), ao); }
  
  /**
   * <p>
   *   Says that pass on this.
   * </p>
   */
  void pass(){ m_pass=true; }
  
  /**
   * <p>
   *   Tells if do pass on this.
   * </p>
   */
  boolean doPass(){ return m_pass; }
  
  @Override
  public String toString() 
  {
    CharArrayWriter caw=new CharArrayWriter();
    PrintWriter pw=new PrintWriter(caw);
    
    pw.println("case name="+getName());
    pw.println("Mine:");
    pw.println(m_mine);
    pw.println("keywords: "+getKeywords());
    // TODO
    
    pw.flush();
    return caw.toString();
  }
  
}